﻿namespace UnitTests.Domain
{
	using Core.Domain;
	using Core.Infrastructure;
	using Microsoft.Practices.Unity;

	internal class TestEnvironment
	{		
		public TestEnvironment()
		{
			this.Container = new UnityContainer();
			this.DomainSessionFactory = new StubDomainSessionFactory(this.Container);
			this.AccountRepository = new StubAccountRepository();
			this.PersonRepository = new StubPersonRepository();

			this.Container
				.RegisterInstance(this.Container)
				.RegisterInstance<IDomainSessionFactory>(this.DomainSessionFactory)
				.RegisterType<DomainSession, StubDomainSession>()
				.RegisterInstance<IAccountRepository>(this.AccountRepository)
				.RegisterInstance<IPersonRepository>(this.PersonRepository);
		}

		public IUnityContainer Container
		{
			get;
			private set;
		}

		public StubDomainSessionFactory DomainSessionFactory
		{
			get;
			private set;
		}

		public StubAccountRepository AccountRepository
		{
			get;
			private set;
		}

		public StubPersonRepository PersonRepository
		{
			get;
			private set;
		}

		public RegistrationService CreateRegistrationService()
		{
			return this.Container.Resolve<RegistrationService>();
		}
	}
}